import axios from '@/libs/axios1';
import qs from 'qs';
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' };
let skill = '/self-study/careerSkill';
let skillchapter = '/self-study/careerSkillchapters';
let skillpoint = '/self-study/careerSkillPointRelation';
let careerSkillLink = `/self-study/careerSkillLink`;
export const addByExcellentUser = (userId) => {
    return axios({
        url: `${skill}/addByExcellentUser/${userId}`,
        method: 'POST',
        headers: jsonHeaders
    });
};

//添加技能树
export const addSkill = (classInfo) => {
    return axios({
        url: `${skill}/add`,
        method: 'POST',
        headers: jsonHeaders,
        data: classInfo
    });
};

//修改技能树
export const modifySkill = (classInfo) => {
    return axios({
        url: `${skill}/update`,
        method: 'PUT',
        headers: jsonHeaders,
        data: classInfo
    });
};

//删除技能树
export const delSkill = (id) => {
    return axios({
        url: `${skill}/del/${id}`,
        method: 'DELETE',
        headers: jsonHeaders
    });
};

//获取技能树列表
export const querySkill = (params) => {
    return axios({
        url: `${skill}`,
        method: 'get',
        headers: jsonHeaders,
        params: params
    });
};
//检查技能树是否可用
export const checkSkill = (id) => {
    return axios({
        url: `${skill}/check/${id}`,
        method: 'get',
        headers: jsonHeaders
    });
};

//查询技能树章节
export const querySkillChapter = (id) => {
    return axios({
        url: `${skillchapter}/lists/${id}`,
        method: 'get',
        headers: jsonHeaders
    });
};
//创建
export const addSkillChapter = (data) => {
    return axios({
        url: `${skillchapter}/add`,
        method: 'post',
        headers: jsonHeaders,
        data
    });
};
//修改
export const modifySkillChapter = (data) => {
    return axios({
        url: `${skillchapter}/update`,
        method: 'put',
        headers: jsonHeaders,
        data
    });
};
//删除
export const delSkillChapter = (id) => {
    return axios({
        url: `${skillchapter}/del/${id}`,
        method: 'delete',
        headers: jsonHeaders
    });
};
//节点复制
export const nodeCopy = (params, data) => {
    return axios({
        url: `${skillchapter}/copy`,
        method: 'post',
        params,
        data,
        headers: jsonHeaders
    });
};
//技能点绑定的增删改
export const querySkillPoint = (params) => {
    return axios({
        url: `${skillpoint}`,
        method: 'get',
        headers: jsonHeaders,
        params
    });
};
//创建
export const addSkillPoint = (data) => {
    return axios({
        url: `${skillpoint}/add`,
        method: 'post',
        headers: jsonHeaders,
        data
    });
};
//修改
export const modifySkillPoint = (data) => {
    return axios({
        url: `${skillpoint}/update`,
        method: 'put',
        headers: jsonHeaders,
        data
    });
};
//删除
export const delSkillPoint = (id) => {
    return axios({
        url: `${skillpoint}/del`,
        method: 'delete',
        data: id,
        headers: jsonHeaders
    });
};
//获取技能树下的是否按顺序学习
export const getSysConfig = (params) => {
    return axios({
        url: `/dictionaries/sysConf/getInfoByName`,
        params,
        method: 'get',
        headers: jsonHeaders
    });
};
//获取收藏技能树详情
export const getCollectSkillPeople = (id, params) => {
    return axios({
        url: `${skill}/pageByCollecter/${id}`,
        params,
        method: 'get',
        headers: jsonHeaders
    });
};

//查询所有连线
export const getAllSkillLinks = (careerSkillId) => {
    return axios({
        url: `${careerSkillLink}/${careerSkillId}`,
        params: {},
        method: 'get',
        headers: jsonHeaders
    });
};

//查询所有节点
export const getAllSkillNodes = (careerSkillId) => {
    return axios({
        url: `${skillchapter}/${careerSkillId}`,
        params: {},
        method: 'get',
        headers: jsonHeaders
    });
};

//创建连线
export const addLink = (data) => {
    return axios({
        url: `${careerSkillLink}/add`,
        method: 'POST',
        data,
        headers: jsonHeaders
    });
};

//删除连线
export const delLink = (id) => {
    return axios({
        url: `${careerSkillLink}/del/${id}`,
        method: 'DELETE',
        headers: jsonHeaders
    });
};

//获取优秀学员生成的技能树
export const getTreeListByExcellentUser = (userId, params) => {
    return axios({
        url: `${skill}/getByExcellentUser/${userId}`,
        method: 'GET',
        params,
        headers: jsonHeaders
    });
};

//分享技能树
export const shareTree = (data) => {
    return axios({
        url: `${careerSkillLink}/shareExcellentStudentSkill`,
        method: 'POST',
        data,
        headers: jsonHeaders
    });
};

//取消分享
export const unShareTree = (roleId, sourceId) => {
    return axios({
        url: `${careerSkillLink}/delExcellentStudentSkill/${roleId}/${sourceId}`,
        method: 'DELETE',
        headers: jsonHeaders
    });
};

//湖区优秀学员分享的岗位角色
export const getShareRoleList = (params) => {
    return axios({
        url: `${careerSkillLink}/pageShareExcellentRole`,
        method: 'GET',
        params,
        headers: jsonHeaders
    });
};

//获取技能树列表
export const querySkillBindDetail = (params) => {
    return axios({
        url: `${skillpoint}/careerSkillPointRelationPageById`,
        method: 'get',
        headers: jsonHeaders,
        params: params,
        paramsSerializer: (params) => {
            return qs.stringify(params, { indices: false });
        }
    });
};


